﻿using System;

using NUnit.Framework;
using NUnit.Framework.Constraints;

namespace CoreLib.NUnit.Constraints
{
    public abstract class ActionConstraint : Constraint
    {
        private string _message = string.Empty;

        public override bool Matches( object actual )
        {
            if( actual.GetType() != typeof( Action ) )
            {
                _message = "Actual needs to be an Action";
                return false;
            }
            return Matches( (Action)actual );
        }

        public override void WriteDescriptionTo( MessageWriter writer )
        {
            writer.WriteLine( _message );
            writer.WriteLine( GetMessage() );
        }

        protected abstract bool Matches( Action actualAction );
        protected abstract string GetMessage();
    }
}
